package com.ys.web.service.impl;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.ys.web.pojo.SpecialCompanyInfo;
import com.ys.web.service.SpecialCompanyService;

@Service("specialCompanyService")
@Transactional
public class SpecialCompanyServiceImpl implements SpecialCompanyService{

	@Resource(name = "jdbcTemplate")
	private JdbcTemplate jdbcTemplate;
	@Override
	public String getSpecialCompanyById(int companyId) {
		String sql = "select companyLabel from specialCompany where companyId="+companyId;
		List<Map<String,Object>> listMap = jdbcTemplate.queryForList(sql);
		
		if(!listMap.isEmpty()){
			return (String) listMap.get(0).get("companyLabel");
		}
		return null;
	}
	@Override
	public String addSpecialCompany(int companyId, String companyName,
			String industryName) {
		String sql = "insert into specialCompany values ("+companyId+",'"+companyName+"','"+industryName+"','特殊消费用户')";
		int result = jdbcTemplate.update(sql);
		if(result>0){
			return "标记成功";
		}
		return "标记失败";
	}
	@Override
	public String removeSpecialCompany(int companyId) {
		String sql = "delete from specialCompany where companyId="+companyId;
		int result = jdbcTemplate.update(sql);
		if(result>0){
			return "标记成功";
			
		}
		return "标记失败";
	}

}
